package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(30)" json:"username"`
	Password string `gorm:"type:varchar(50)" json:"password"`
}

type Movie struct {
	gorm.Model
	Title        string `gorm:"type:varchar(50)" json:"title"`
	Content      string `gorm:"type:text" json:"content"`
	Img          string `gorm:"type:varchar(255)" json:"img"`
	UserId       int    `gorm:"type:int" json:"user_id"`
	User         User   `gorm:"foreignKey:UserId" json:"user"`
	LikeCount    int    `gorm:"type:int" json:"like_count"`
	CommentCount int    `gorm:"type:int" json:"comment_count"`
}

type Like struct {
	gorm.Model
	UserId  int   `gorm:"type:int" json:"user_id"`
	User    User  `gorm:"foreignKey:UserId" json:"user"`
	MovieId int   `gorm:"type:int" json:"movie_id"`
	Movie   Movie `gorm:"foreignKey:MovieId" json:"movie"`
}

type Comment struct {
	gorm.Model
	Content string `gorm:"type:text" json:"content"`
	UserId  int    `gorm:"type:int" json:"user_id"`
	User    User   `gorm:"foreignKey:UserId" json:"user"`
	MovieId int    `gorm:"type:int" json:"movie_id"`
	Movie   Movie  `gorm:"foreignKey:MovieId" json:"movie"`
}
